#ifndef AVIATION_TIME_24_H
#define AVIATION_TIME_24_H

#include "util.h"

#include <string>

#include <boost/serialization/nvp.hpp>

// NB: We call this class 'time_24.h' to avoid conflict with the c library 'time.h'.

namespace aviation
{

/// This class represents a time in the form hhmm.
class Time
{
public:

	typedef std::string String;
	
	//Constructors

	/// Initialises time.
	Time(); 
	/// Constructs a time from the relevant part of a line from an FCGDATA file.
	Time(const String& fcgString); 
	/// Copies the time from another.
	Time(const Time& other); 
	/// Destructs the time.
	~Time();

	//Operators

	/// Assigns the contents of one time to another
	Time& operator=(const Time& other);

	/// Tests for equality between two times.
	/// \returns true if they are the same and false if they are different. 
	const bool operator==(const Time& other) const;

	/// Tests for inequality between two times.
	/// \returns true if they are different and false if they are the same.
	const bool operator!=(const Time& other) const;

	/// \returns true if one time is strictly less than another.
	const bool operator<(const Time& other) const;

	//Accessors

	/// Gets the minutes as an integer.
	const unsigned int GetMinutes() const;
	/// Gets the hours as an integer.
	const unsigned int GetHours() const;
	/// Gets the time as a string.
	const String AsString() const;

	/// Serialization (file I-O) function.
	/// \param ar A boost::archive formatter type.
	/// \param version The file version.
	template <class Archive>
	void serialize(Archive& ar, unsigned int version);

private:

	unsigned int m_minutes;
	unsigned int m_hours;

};

template <class Archive>
void Time::serialize(Archive& ar, unsigned int version)
{
	ar & BOOST_SERIALIZATION_NVP(m_minutes);
	ar & BOOST_SERIALIZATION_NVP(m_hours);
}

} // namespace aviation

#endif // AVIATION_TIME_24_H